#include "stm32f10x.h"                  // Device header
#include "Delay.h"
#include "OLED.h"
#include "MyDMA.h"
//#include "OLED_Font.h"
//DMA数据转运
//定义DMA的配置——属于系统里头
//配置DMA转运的源端数组和目的数组
uint8_t DataA[]={0x01,0x02,0x03,0x04};
uint8_t DataB[]={0,0,0,0};
int main(void){
	OLED_Init();
//	//首先需要确定定义的数据，是不是真的存储在相应的地址区间——存储器映像
	//uint8_t aa=0x66;
//const uint8_t aa1=0x66;
//	OLED_ShowHexNum(1,1,aa,2);
//	OLED_ShowHexNum(2,1,(uint32_t)&aa,8); //对应地址为20000000 对应地址在SRAM区
//	OLED_ShowHexNum(3,1,(uint32_t)&aa1,8);//对应地址为08000E30 对应地址在Flash地址
//	OLED_ShowHexNum(4,1,(uint32_t)&ADC1->DR,8);//对应地址为4001244C 对应地址在外设地址区中，是ADC1的数据寄存器地址，此地址是固定的
	MyDMA_Init((uint32_t)DataA,(uint32_t)DataB,4);
	
	OLED_ShowString(1,1,"DataA");
	OLED_ShowString(3,1,"DataB");	
	OLED_ShowHexNum(1,8,(uint32_t)DataA,8);
	OLED_ShowHexNum(3,8,(uint32_t)DataB,8);	
	
	OLED_ShowHexNum(2,1,DataA[0],2);
	OLED_ShowHexNum(2,4,DataA[1],2);
	OLED_ShowHexNum(2,7,DataA[2],2);
	OLED_ShowHexNum(2,10,DataA[3],2);
	OLED_ShowHexNum(4,1,DataB[0],2);
	OLED_ShowHexNum(4,4,DataB[1],2);
	OLED_ShowHexNum(4,7,DataB[2],2);
	OLED_ShowHexNum(4,10,DataB[3],2);

	
	while(1){
		DataA[0]++;
		DataA[1]++;
		DataA[2]++;
		DataA[3]++;
		
		OLED_ShowHexNum(2,1,DataA[0],2);
		OLED_ShowHexNum(2,4,DataA[1],2);
		OLED_ShowHexNum(2,7,DataA[2],2);
		OLED_ShowHexNum(2,10,DataA[3],2);
		OLED_ShowHexNum(4,1,DataB[0],2);
		OLED_ShowHexNum(4,4,DataB[1],2);
		OLED_ShowHexNum(4,7,DataB[2],2);
		OLED_ShowHexNum(4,10,DataB[3],2);	

		Delay_ms(1000);
		
		MyDMA_Tranfer();
		
		OLED_ShowHexNum(2,1,DataA[0],2);
		OLED_ShowHexNum(2,4,DataA[1],2);
		OLED_ShowHexNum(2,7,DataA[2],2);
		OLED_ShowHexNum(2,10,DataA[3],2);
		OLED_ShowHexNum(4,1,DataB[0],2);
		OLED_ShowHexNum(4,4,DataB[1],2);
		OLED_ShowHexNum(4,7,DataB[2],2);
		OLED_ShowHexNum(4,10,DataB[3],2);	
		
		Delay_ms(1000);
	}
}
